package com.itheima.app.interceptor;

import com.itheima.domain.db.User;

public class UserHolder {

    //定义本地线程变量,存储用户的数据
    private static ThreadLocal<User> local = new ThreadLocal<>();

    //存入数据
    public static void set(User user) {
        local.set(user);
    }
    //获取数据(对象)
    public static User get() {
        return local.get();
    }
    //获取数据(id)
    public static Long getId() {
        return local.get().getId();
    }
    //删除数据
    static void remove() {
        local.remove();
    }
}
